import request from "@/utils/request";

// 回收登记列表
export function listTable(query) {
  return request({
    url: "/purchase/register/list",
    method: "get",
    params: query,
  });
}
// 	新增回收登记
export function addRegister(data) {
  return request({
    url: "/purchase/register",
    method: "post",
    data,
  });
}
// 	删除回收登记
export function delRegister(itemIds) {
  return request({
    url: "/purchase/register/" + itemIds,
    method: "delete",
  });
}

// 	删除回收登记
export function getRegister(id) {
  return request({
    url: "/purchase/register/" + id,
    method: "get",
  });
}

// 修改回收登记
export function updateRegister(data) {
  return request({
    url: "/purchase/register/",
    method: "put",
    data,
  });
}

// 退货
export function refund(id) {
  return request({
    url: "/purchase/register/refund/" + id,
    method: "put",
  });
}

// 重新入库
export function retry(id) {
  return request({
    url: "/purchase/register/retry/" + id,
    method: "put",
  });
}

// 图片上传
export function uploadApi(data) {
  return request({
    url: "/purchase/register/upload",
    method: "post",
    data,
    "Content-Type": 'multipart/form-data'
  });
}

// 生成code
export function batchQrcode(data) {
  return request({
    url: "/purchase/register/qrcode",
    method: "post",
    data,
  });
}

export function qrcode(data) {
  return request({
    url: "/purchase/register/qrcode/"+data,
    method: "get",
  });
}

/** 分配库位 */
export function allocateLocation(id, shelfStatus) {
  return request({
    url: `/purchase/register/allocateLocation/${id}`,
    method: "get",
    params: { id, shelfStatus }
  });
}

/** 取消分配库位 */
export function cancelAllocateLocation(params) {
  return request({
    url: `/purchase/register/cancelAllocate`,
    method: "get",
    params
  });
}
